﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
namespace OtherDevice
{
    [Description("比例阀控制")]
    public class Aventics : COM_Base
    {
        
        bool bStatus = false;
        public int Close(int channel)
        {
            
            throw new NotImplementedException();
        }

        public int Init(string CommPort)
        {
            int ret = 0;
            string parameter = "9600,n,8,1";
            COM_Base C = new COM_Base();

            ret = InitComAddEvent(CommPort, parameter);
            if (ret != (int)0)
            {
                return ret;
            }
            bStatus = true;

            return ret;
        }

        public int Set(int channel, double value)
        {
            string info = $"#0{channel}D0+{value:F3}\r\n";
            if (info.Length == 12)
                info.Insert(5, "0");
            byte[] byteArray = System.Text.Encoding.ASCII.GetBytes(info);
            var ret =  SendAndReceiveData(byteArray, 2000);
            return 0;
        }
    }
}
